package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import model.ModelTileCK;

import various.Constants;
import various.Formula;
import view.ViewBoard;
import view.ViewSquare;

public class ControllerGrid implements ActionListener{
	ViewBoard vb;	
	
	public ControllerGrid(ViewBoard vb)
	{
		this.vb=vb;
	}

	public void actionPerformed(ActionEvent e) {
		String etiquette[] = e.getActionCommand().split(" ");
		if(etiquette[0].equalsIgnoreCase("case"))
		{
			//			((ViewSquare) this.vb.pangrid.getComponent(Integer.parseInt(etiquette[1]))).changeIcon(this.vb.imagePicked);
			//			//on affecte l'image pioch�e
			//			this.vb.imagePicked = this.vb.mb.randImage();
			//			((ViewSquare) this.vb.pangrid.getComponent(Integer.parseInt(etiquette[1]))).setDisabledIcon(((ViewSquare) this.vb.pangrid.getComponent(Integer.parseInt(etiquette[1]))).getIcon());
			//			((ViewSquare) this.vb.pangrid.getComponent(Integer.parseInt(etiquette[1]))).setEnabled(false);

			//on recup la position cliqu�e
			int x = Formula.getY(Integer.parseInt(etiquette[1]),Constants.GRIDSIZE);
			int y = Formula.getX(Integer.parseInt(etiquette[1]),Constants.GRIDSIZE);
			//on regarde si c'est une case posable
			System.out.println("la case cliqe est "+etiquette[1]);
			System.out.println(" le y "+Formula.getY(Integer.parseInt(etiquette[1]),Constants.GRIDSIZE));
			System.out.println(" le x "+Formula.getX(Integer.parseInt(etiquette[1]),Constants.GRIDSIZE));
			

			this.vb.frame.validate();
		}
	}

	
}